<style type="text/css">
.img-thumbnail {width: 100px;height: 100px;}
</style>
<div class="form-group">
    <label class="col-sm-2 control-label">排序</label>
    <div class="col-sm-9 col-xs-12">
        {ife 'groups.goods' $item}
        <input type='text' class='form-control' name='displayorder' value="{$item['displayorder']}" />
        <span class="help-block">数字越大，排名越靠前,如果为空，默认排序方式为创建时间</span>
        {else}
        <div class='form-control-static'>{$item['displayorder']}</div>
        {/if}
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label must">标题</label>
    <div class="col-sm-9 col-xs-12">
        {ife 'groups.goods' $item}
        <div class='goodstype goodstype0'  {if $item['goodstype']!=0}style="display:none"{/if}>
        <?php echo tpl_selector('goodsid',
            array(
            'required'=>true,
        'preview'=>false,
        'value'=>$item['title'],
        'url'=>webUrl('groups/goods/query'),
        'items'=>$item
        ,'readonly'=>false,
        'buttontext'=>'选择商品',
        'placeholder'=>'请输入商品标题','callback'=>'select_goods'))
		?>
        <span class="help-block">【选择商品】可从商城商品库中选择商品</span>
    </div>
    {else}
    <div class='form-control-static'>{$item['title']}</div>
    {/if}
</div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label">副标题</label>
    <div class="col-sm-9 col-xs-12">
        {ife 'groups.goods' $item}
        <input type='text' id='description' class='form-control' name='description' value="{$item['description']}" />
        {else}
        <div class='form-control-static'>{$item['description']}</div>
        {/if}
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label must">分类</label>
    <div class="col-sm-9 col-xs-12">
        {ife 'groups.goods' $item}
        <select class='form-control' name='category' data-rule-required='true' data-msg-required='请选择分类'>
            <option value=''>--请选择分类--</option>
            {loop $category $cate}
            <option value="{$cate['id']}" {if $item['category']==$cate['id']}selected{/if}>{$cate['name']}</option>
            {/loop}
        </select>
        {else}
        <div class='form-control-static'>{$item['catename']}</div>
        {/if}
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label must">商品图片</label>
    <div class="col-sm-9 col-xs-12 gimgs">
        {ife 'groups.goods' $item}
        {php echo tpl_form_field_multi_image('thumbs',$piclist)}
        <span class="help-block image-block" style="display: block;">第一张为缩略图，建议为正方型图片，其他为详情页面图片，尺寸建议宽度为640，并保持图片大小一致</span>
        <span class="help-block">您可以拖动图片改变其显示顺序 </span>
        {else}
        {loop $piclist $p}
        <a href='{php echo tomedia($p)}' target='_blank'>
            <img src="{php echo tomedia($p)}" style='height:100px;border:1px solid #ccc;padding:1px;float:left;margin-right:5px;' />
        </a>
        {/loop}
        {/if}
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label">拼团价格</label>
    <div class="col-sm-9 col-xs-12">
        {ife 'groups.goods' $item}
        <div class="input-group">
            <input type="text" name="groupsprice" class="form-control" value="{$item['groupsprice']}" />
            <span class="input-group-addon">元 原价</span>
            <input type="text" name="price" class="form-control" value="{$item['price']}" />
            <span class="input-group-addon">元</span>
        </div>
        <span class='help-block'>尽量填写完整，有助于于商品销售的数据分析</span>
        {else}
        <div class='form-control-static'>拼团价：{$item['groupsprice']} 元， 原价：{$item['price']} 元 </div>
        {/if}
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">购买次数限制</label>
    <div class="col-xs-12 col-sm-9">
        <div class="input-group">
            {ife 'groups.goods' $item}
            <input type="text" name="purchaselimit" class="form-control" value="{$item['purchaselimit']}" />
            <span class="input-group-addon">次</span>
            {else}
            <div class='form-control-static'>{$item['purchaselimit']}次</div>
            {/if}
        </div>
        <span class='help-block'>个人购买次数限制，默认是0，没有次数限制</span>
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">是否单购</label>
    <div class="col-xs-2 col-sm-2">
        {ife 'groups.goods' $item}
        <label class="radio radio-inline">
            <input type="radio" name="single" value="1" {if intval($item['single']) ==1 }checked="checked"{/if}> 是
        </label>
        <label class="radio radio-inline">
            <input type="radio" name="single" value="0" {if intval($item['single']) ==0}checked="checked"{/if}> 否
        </label>
        {else}
        <label class="radio radio-inline">
        {if intval($item['single']) ==1 }是{else}否{/if}
        </label>
        {/if}
    </div>
    <div class="col-sm-7 col-xs-7" id="single" {if intval($item['single']) == 0 }style="display:none;"{/if}>
    <label class="col-xs-2 col-sm-2 control-label">单购价</label>
        <div class="input-group">
            {ife 'groups.goods' $item}
            <input type='text' class='form-control' name='singleprice' value="{$item['singleprice']}" />
            <span class="input-group-addon">元</span>
            {else}
            {if intval($item['single']) ==1 }
            <div class='form-control-static'>{$item['singleprice']}元</div>
            {/if}
            {/if}
        </div>
    </div>
</div>
<div class="form-group  goodstype goodstype0">
    <label class="col-sm-2 control-label">数量</label>
    <div class="col-sm-9 col-xs-12">
        {ife 'groups.goods' $item}
        <div class="input-group">
            <input type='text' class='form-control' name='goodsnum' value="{if $item['goodsnum']}{$item['goodsnum']}{else}1{/if}" />
        </div>
        <span class="help-block">拼团商品自定义数量，默认是1</span>
        {else}
        <div class='form-control-static'>{$item['goodsnum']}</div>
        {/if}
    </div>
</div>
<div class="form-group  goodstype goodstype0">
    <label class="col-sm-2 control-label">单位</label>
    <div class="col-sm-9 col-xs-12">
        {ife 'groups.goods' $item}
        <div class="input-group">
            <input type='text' class='form-control' name='units' value="{if $item['units']}{$item['units']}{else}件{/if}" />
        </div>
        <span class="help-block">拼团商品自定义单位，如果不填写默认是【件】</span>
        {else}
        <div class='form-control-static'>{$item['units']}</div>
        {/if}
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label">已出售数</label>
    <div class="col-sm-6 col-xs-12">
        {ife 'groups.goods' $item}
        <div class="input-group">
            <input type="text" name="sales" id="sales" class="form-control" value="{$item['sales']}" />
            <span class="input-group-addon">件</span>
        </div>
        <span class="help-block">物品虚拟出售数，会员下单此数据就增加, 无论是否支付</span>
        {else}
        <div class='form-control-static'>{$item['sales']} 件</div>
        {/if}
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label">已成团数</label>
    <div class="col-sm-6 col-xs-12">
        {ife 'groups.goods' $item}
        <div class="input-group">
            <input type="text" name="teamnum" id="teamnum" class="form-control" value="{$item['teamnum']}" />
            <span class="input-group-addon">人</span>
        </div>
        <span class="help-block">拼团成团虚拟数量，拼团成功数量会增加</span>
        {else}
        <div class='form-control-static'>{$item['teamnum']} 人</div>
        {/if}
    </div>
</div>
<div class="form-group dispatch_info">
    <label class="col-sm-2 control-label">运费设置</label>
    <div class="col-sm-6 col-xs-12">
        {ife 'groups.goods' $item}
        <div class="input-group">
            <span class='input-group-addon' style='border:none;display: none;'>
                <label class="radio-inline" style='margin-top:-7px;' >
                    <input type="radio" name="dispatchtype" value="0" {if empty($item['dispatchtype'])}checked="true"{/if}   /> 运费模板
                </label>
            </span>
            <select class="form-control tpl-category-parent select2" id="dispatchid" name="dispatchid" style="display: none;">
                <option value="0">默认模板</option>
                {loop $dispatch_data $dispatch_item}
                <option value="{$dispatch_item['id']}" {if $item['dispatchid'] == $dispatch_item['id']}selected="true"{/if}>{$dispatch_item['dispatchname']}</option>
                {/loop}
            </select>
            <span class='input-group-addon' style='border:none;display: none;'><label class="radio-inline"  style='margin-top:-7px;' >
                <input type="radio"name="dispatchtype" value="1" {if $item['dispatchtype'] == 1}checked="true"{/if}  /> 统一邮费</label>
            </span>

            <input type="text" name="freight" id="dispatchprice" class="form-control" value="{$item['freight']}" />
            <span class="input-group-addon">元</span>
        </div>
        {else}
        <div class='form-control-static'>{$item['freight']} 元</div>
        {/if}
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">开团人数</label>
    <div class="col-xs-12 col-sm-9">
        <div class="input-group">
            {ife 'groups.goods' $item}
            <input type="text" name="groupnum" class="form-control" value="{$item['groupnum']}" />
            <span class="input-group-addon">人</span>
            {else}
            <div class='form-control-static'>{$item['singleprice']} 人</div>
            {/if}
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">组团限时(整数小时)</label>
    <div class="col-xs-12 col-sm-9">
        <div class="input-group">
            {ife 'groups.goods' $item}
            <input type="text" name="endtime" class="form-control" value="{$item['endtime']}" />
            <span class="input-group-addon">小时</span>
            {else}
            <div class='form-control-static'>{$item['singleprice']} 小时</div>
            {/if}
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">状态</label>
    <div class="col-xs-12 col-sm-8">
        <div class="input-group">
            {ife 'groups.goods' $item}
            <label class="radio radio-inline">
                <input type="radio" name="status" value="1" {if intval($item['status']) ==1 }checked="checked"{/if}> 上架
            </label>
            <label class="radio radio-inline">
                <input type="radio" name="status" value="0" {if intval($item['status']) ==0}checked="checked"{/if}> 下架
            </label>
            {else}
            <div class='form-control-static'>{if intval($item['status']) ==1 }上架{else}下架{/if}</div>
            {/if}
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">拼团首页显示</label>
    <div class="col-xs-12 col-sm-8">
        <div class="input-group">
            {ife 'groups.goods' $item}
            <label class="radio radio-inline">
                <input type="radio" name="isindex" value="1" {if intval($item['isindex']) ==1 }checked="checked"{/if}> 是
            </label>
            <label class="radio radio-inline">
                <input type="radio" name="isindex" value="0" {if intval($item['isindex']) ==0}checked="checked"{/if}> 否
            </label>
            {else}
            <div class='form-control-static'>{if intval($item['isindex']) ==1 }是{else}否{/if}</div>
            {/if}
        </div>
    </div>
</div>
{if !empty($id)}
<div class="form-group" style="display:none;">
    <label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">添加日期</label>
    <div class="col-xs-12 col-sm-8">
        <p class="form-control-static">{php echo date('Y-m-d H:i', $item['createtime']);}</p>
    </div>
</div>
{/if}
<script language="javascript">
    require(['jquery.ui'],function(){
        $('.multi-img-details').sortable();
    })
</script>
<script type="text/javascript">
$(function(){
    $("input[name='single']").click(function(){
        if(this.value== true){
            $("#single").show()
        }else{
            $("#single").hide();
        }
    })
})
</script>